Lesson 1 - Hello World with Python and Jupyter

You can execute the line of code below by clicking in the cell below and pressing Shift+Enter.


In [ ]:
print ("hello World")

Next, copy or type the same line of code into a text file and save the file as hello.py.

You could execute the code in the file using the python command at the system prompt, like this C:\>python textfiles\hello.py.

In a Jupyter notebook, an exclamation point is used to send the command to the operating system. Press Shift+Enter in the cell below to run the code in the hello.py file.


In [ ]:
!python textfiles\hello.py  # ! accesses the operating system without leaving the notebook

In [ ]:
%quickref   # brings up some info about jupyter magics

Play around with what you have learned . . .


In [ ]:
import math   # now I'm just playing around, not following Socratica

Pythagorean Theorem: $c = \sqrt{a^2 + b^2}$


In [ ]:
def pythag(a,b):
    return math.sqrt(a**2 + b**2)       # defined a python function

In [ ]:
pythag(3,4)                             # used my function

In [ ]:
math.sin(math.pi / 2)                   # playing with math.sin and math.pi

In [ ]:
5 / 2

In [ ]:
5 // 2

In [ ]: